import contextlib
import random
from typing import Generator, Any

@contextlib.contextmanager
def rand_state(seed: int | None = None) -> Generator:
    state: tuple[Any, ...] = random.getstate()
    random.seed(seed)
    try:
        yield
    finally:
        random.setstate(state)

def main() -> None:
    with rand_state(100):
        print(random.randrange(0, 100))
        print(random.random())

    print(random.randint(0, 100))

if __name__ == "__main__":
    main()
